Skip to content

Program Testing

Alt text

Trace table

  • You can also manually work through a program to check that it works as it should, using tools such as a trace table.
  • Trace tables show the process of dry-running a program with columns showing the values of each variable as it changes.
CASE sign OF
    '+' : answer ← number1 + number2
    '-' : answer ← number1 - number2
    '*' : answer ← number1 * number2
    '/' : answer ← number1 / number2
    OTHERWISE answer ← 0
ENDCASE
IF answer <> 0 THEN
       OUTPUT answer
ENDIF
number1number2signanswerOUTPUT
2010+3030
20103030
2010*200200
2010/22
2010?0
200/undefined

Errors

  • Normally, there are three types of errors:

Run-time error

  • an error that causes program execution to crash or freeze

Syntax error

  • an error in which a program statement does not follow the rules of the language

Logic error

  • an error in the logic of the solution that causes it not to behave as intended

Errors

An error that causes program execution to crash or freeze:

an error in which a program statement does not follow the rules of the language:

an error in the logic of the solution that causes it not to behave as intended:

[0/3]

Program testing

  • There needs to be a test strategy set out in the analysis stage of the program development lifecycle showing an overview of the testing required to meet the requirements specified.

  • In order to clarify what tests need to be performed, a test plan is drawn up showing all the stages of testing and every test that will be performed. As the testing is carried out, the results of the tests can be added to the plan showing that the program has met its requirements.

  • During the program design stage, pseudocode is written. This can be tested using a dry run, in which the developer works through a program or module from a program manually and documents the results using a trace table.

Test data

  • A set of test data is all the items of data required to work through a solution.
    • normal data – data that is accepted by a program (-1,1,20)
    • abnormal data – data that is rejected by a program(a,!)
    • extreme data – the largest/smallest data value that is accepted by a program(0,18)
    • boundary data – the largest/smallest data value that is accepted by a program and the corresponding smallest/ largest rejected data value(0,18,-1,1,17,19)
DECLARE Age: INTEGER
OUTPUT “Please input your age:”
INPUT Age
IF Age >= 18 THEN
    OUTPUT ”Adult”
ELSE
    IF Age > 0 THEN
        OUTPUT “Child”
    ELSE
        OUTPUT “Error”
    ENDIF
ENDIF

Test data

data that is accepted by a program:

data that is rejected by a program:

the largest/smallest data value that is accepted by a program:

the largest/smallest data value that is accepted by a program and the corresponding smallest/ largest rejected data value:

[0/4]

Test types

  • As the program is being developed the following types of testing are used:

    • White-box testing is the detailed testing of how each procedure works. This involves testing the structure and logic of every path through a program module.
    • Black-box testing tests a module’s inputs and outputs.
    • Integration testing is the testing of any separately written modules to ensure that they work together, during the testing phase of the program development lifecycle. If any of the modules have not been written yet, this can include stub testing, which makes use of dummy modules for testing purposes.
  • When the program has been completed, it is tested as a whole:

    • Alpha testing is used first. The completed, or nearly completed, program is tested in-house by the development team.
    • Beta testing is then used. The completed program is tested by a small group of users before it is generally released.
    • Acceptance testing is then used for the completed program to prove to the customer that it works as required in the environment in which it will be used.

Test types

tests a module’s inputs and outputs

is then used. The completed program is tested by a small group of users before it is generally released

[0/2]

Program maintenance

  • Program maintenance is not like maintaining a piece of equipment by replacing worn out parts.
  • Programs do not wear out, but they might not work correctly in unforeseen circumstances.
  • Logic or run-time errors that require correction may occur from time to time, or users may want to use the program in a different way.
  • Program maintenance can usually be divided into three categories:
    • Corrective maintenance is used to correct any errors that appear during use, for example trapping a run-time error that had been missed during testing.
    • Perfective maintenance is used to improve the performance of a program during its use, for example improving the speed of response.
    • Adaptive maintenance is used to alter a program so it can perform any new tasks required by the customer, for example working with voice commands as well as keyboard entry.

Test data

is used to improve the performance of a program during its use, for example improving the speed of response

[0/1]